#ifndef TEAMMEMBERMODEL_H
#define TEAMMEMBERMODEL_H

#include <QStandardItemModel>
#include <QSqlTableModel>
#include <QSqlRelationalTableModel>

class teamMemberModel : public QStandardItemModel
{
    enum viewCols {
        col_team_or_member_view,
        col_id_view,
        col_organization_view,
        col_change_view,
        col_member_view
    };

    Q_OBJECT
public:
    teamMemberModel(QSqlDatabase db, QObject *parent = 0);
    
signals:
    
public slots:
    bool submitManual();
    bool submit();
    void revert();
    bool select();
    void addChild(QModelIndex root_index, QString name, int childId, bool isManualAdd = true, int team_member_id = 1);
    void dropChild(QModelIndex index);
    bool insertRow(int row, bool isManualSubmit = true, const QModelIndex & parent = QModelIndex());
    bool removeRow(int row, const QModelIndex &parent = QModelIndex());
    void setChageFlag(QModelIndex topLeft, QModelIndex botRight);

private:
    QSqlDatabase    dbase;
    QSqlTableModel *modelMember;
    QSqlTableModel *modelTeam;
    QSqlRelationalTableModel *modelTeamMember;
    int col_id_teamMember, col_team_teamMember, col_member_teamMember;
    int col_id_team, col_title_team, col_organization_team;
    int col_id_member, col_name_member;
};

#endif // TEAMMEMBERMODEL_H
